<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-5-22
 * Time: 下午6:12
 */

namespace ActionsHttp;

use Data\Restaurant_DAO;
use Data\Food_groups_DAO;

class RestaurantFoodUpdateOrder extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        // 商铺id
        $restaurant_id = $_SESSION[RESTAURANT_ID];
        $restaurant_id = 1;

        // 商品分类id
        $food_groups_id = (int)$this->data[FOOD_GROUP_ID];

        $food_groups_record = Food_groups_DAO::getRecordByIdResId($food_groups_id,$restaurant_id);
        if (!$food_groups_record) {
            return $this->SendErrMsg("参数错误，没有该商品分类");
        }

        // 商品排序(数组)
        $food_order = $this->data[FOOD_ORDER];

        // 更新
        $food_groups_record->setFOOD_ORDER($food_order);

        // 更新数据库
        Food_groups_DAO::update($food_groups_record);

        // 返回数据
        $this->ResponseDataToCurrentClient();
    }
}